{{ extend 'layout.html' }}
{{ include 'catalog.html' }}


<h1>{{= product.name }}</h1>

<img src="{{= URL(r=request, f='show', args=(product.large_image if product.large_image else product.small_image)) }}" height="200px"/>

{{= product_form }}

<p>{{= XML(product.description) }}</p>

{{ if product.allow_rating and product.rating > 0: }}
        {{= '%.1f' % product.rating }}/5.0 rating,
    {{ pass }}
    {{ if product.quantity_in_stock != UNDEFINED: }}
        {{ if product.quantity_in_stock < 1: }}
            low stock
        {{ else: }}
            {{= product.quantity_in_stock }} in stock
        {{ pass }}        
    {{ pass }}
{{ pass }}    

<br/>
<br/>
{{ if suggested: }}
<h2>You may also be interested in:</h2>
    {{ show(suggested) }}
{{ pass }}


{{ if product.allow_rating: }}
<br/>
    {{ if comments: }}
<h2>Visitors' comments</h2>
<p><ul>
        {{ for comment in comments: }}
    <li>{{= comment.author }} says <i>"{{= comment.body }}"</i></li>
        {{ pass }}
</ul>
</p>
    {{ pass }}
    {{= comment_form }}
{{ pass }}



<script type="text/javascript">
    var total_price = {{= product.price }};
        
    function update_price(e, option_price) {
        if($(e).is(':checked')) total_price += option_price;
        else total_price -= option_price;
        $("#total_price").text('$' + Math.round(100*total_price)/100);
    }
</script>